package com.church.action;

import java.util.Map;

import com.church.services.QandaServices;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;

public class AddQuest extends ActionSupport {
	/**
	 * 
	 */
	private static final long serialVersionUID = 32L;
	private QandaServices qandaServices;
	private String subject;
	private String quest;
	private String response;

	public QandaServices getQandaServices() {
		return qandaServices;
	}

	public void setQandaServices(QandaServices qandaServices) {
		this.qandaServices = qandaServices;
	}

	public String getSubject() {
		return subject;
	}

	public void setSubject(String subject) {
		this.subject = subject;
	}

	public String getQuest() {
		return quest;
	}

	public void setQuest(String quest) {
		this.quest = quest;
	}

	public String getResponse() {
		return response;
	}

	public void setResponse(String response) {
		this.response = response;
	}

	public String execute() {
		ActionContext actionContext = ActionContext.getContext();
		Map session = actionContext.getSession();
		String userName = (String) session.get("USER_NAME");
		if (userName != null) {
			response = qandaServices.quest(subject, userName, quest);
			return response;
		}
		return "error";
	}
}
